package com.ycd.gis.service.impl;

import java.util.List;

import com.ycd.common.core.domain.entity.SysUser;
import com.ycd.common.utils.DateUtils;
import com.ycd.common.utils.SecretKeyUtil;
import com.ycd.gis.domain.GisUserDeveloper;
import com.ycd.gis.service.IGisUserDeveloperService;
import com.ycd.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ycd.gis.mapper.GisDevelopProjectMapper;
import com.ycd.gis.domain.GisDevelopProject;
import com.ycd.gis.service.IGisDevelopProjectService;
import com.ycd.common.core.text.Convert;

/**
 * developprojectService业务层处理
 * 
 * @author ruoyi
 * @date 2021-11-25
 */
@Service
public class GisDevelopProjectServiceImpl implements IGisDevelopProjectService 
{
    @Autowired
    private GisDevelopProjectMapper gisDevelopProjectMapper;
    @Autowired
    private IGisUserDeveloperService iGisUserDeveloperService;
    /**
     * 查询developproject
     * 
     * @param id developproject主键
     * @return developproject
     */
    @Override
    public GisDevelopProject selectGisDevelopProjectById(Long id)
    {
        return gisDevelopProjectMapper.selectGisDevelopProjectById(id);
    }

    /**
     * 查询developproject列表
     * 
     * @param gisDevelopProject developproject
     * @return developproject
     */
    @Override
    public List<GisDevelopProject> selectGisDevelopProjectList(GisDevelopProject gisDevelopProject)
    {
        return gisDevelopProjectMapper.selectGisDevelopProjectList(gisDevelopProject);
    }

    /**
     * 新增developproject
     * 
     * @param gisDevelopProject developproject
     * @return 结果
     */
    @Override
    public int insertGisDevelopProject(GisDevelopProject gisDevelopProject)
    {
        gisDevelopProject.setCreateTime(DateUtils.getNowDate());
        String secretKey = SecretKeyUtil.getSecretKey();
        gisDevelopProject.setSecretKey(secretKey);
        GisUserDeveloper gisUserDeveloper = iGisUserDeveloperService.selectGisUserDeveloperByUserId(gisDevelopProject.getUserId());
       Long number = gisUserDeveloper.getProjectNum()+1;
        gisUserDeveloper.setProjectNum(number);
        return gisDevelopProjectMapper.insertGisDevelopProject(gisDevelopProject);
    }

    /**
     * 修改developproject
     * 
     * @param gisDevelopProject developproject
     * @return 结果
     */
    @Override
    public int updateGisDevelopProject(GisDevelopProject gisDevelopProject)
    {
        gisDevelopProject.setUpdateTime(DateUtils.getNowDate());
        return gisDevelopProjectMapper.updateGisDevelopProject(gisDevelopProject);
    }

    /**
     * 批量删除developproject
     * 
     * @param ids 需要删除的developproject主键
     * @return 结果
     */
    @Override
    public int deleteGisDevelopProjectByIds(String ids)
    {
        return gisDevelopProjectMapper.deleteGisDevelopProjectByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除developproject信息
     * 
     * @param id developproject主键
     * @return 结果
     */
    @Override
    public int deleteGisDevelopProjectById(Long id)
    {
        return gisDevelopProjectMapper.deleteGisDevelopProjectById(id);
    }
}
